package com.zzw.controller;

import com.zzw.entity.Result;
import com.zzw.message.MessageConstant;
import com.zzw.pojo.Stock;
import com.zzw.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stock")
public class StockController {
    @Autowired
    private StockService stockService;
    @GetMapping("/findAll")
    public Result findAll(){
        try {
            List<Stock> list = stockService.findAll();
            return new Result(true, MessageConstant.QUERY_STOCK_SUCCESS,list);
        }catch (Exception e){
            return new Result(false,MessageConstant.QUERY_STOCK_FAIL);
        }
    }
}
